package samples.d2.shapes 
{
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import samples.BaseSample;
	import shapes.shapes2D.distribution.Hexagonal;
	import shapes.shapes2D.polygon.RegularPolygon;
	
	/**
	 * ...
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class RegularPolygon4 extends BaseSample
	{
		
		public function RegularPolygon4( version:Boolean = false ) 
		{
			
			
			var radius:Number = 60;
			var points:Vector.<Point> = Hexagonal.distribute( radius * 2, sw + radius * 2, sh + radius * 2 );
			
			
			var po:RegularPolygon;
			var angle:Number = 0;
			var i:int = 0;
			var total:int = points.length;
			for each( var p:Point in points )
			{
				po = new RegularPolygon( p.x, p.y, radius * .5, 5 );
				
				if ( version )
				{
					po.sides = 5;
					angle = ( Math.PI / total ) * i;
					po.scaleX = po.scaleY = 1 - Math.cos( angle );
				}
				else
				{
					po.sides = 3;
					angle = 90 + ( 180 / total ) * i;
					po.scaleX = po.scaleY = 1.25;
					po.rotation =angle
				}
				
				i++;
				po.draw();
				addChild( po );
			}
			
		}
		
	}

}